#include <iostream>
#include <string>
#include <map>
using namespace std;

class Circle 
{
	int radius;
public:
	Circle(int radius) 
	{
		this->radius = radius;
	}
	void draw(int x, int y) 
	{
		cout << "Draw a circle >>> x:" << x << ",y:" << y << ",radius:" << radius << endl;
	}
};

class CircleRepository 
{
private:
	CircleRepository() {}
	map<int, Circle*> repository;
	void create(int radius) 
	{
		Circle* circle = new Circle(radius);
		repository[radius] = circle;
	}
public:
	static CircleRepository* getInstance()
	{
		static CircleRepository* instance;
		if(instance==NULL) instance = new CircleRepository();
		return instance;
	}
	Circle* get(int radius) 
	{
		map<int, Circle*>::iterator iter;
		iter = repository.find(radius);
		if(iter==repository.end()) create(radius);
		return repository[radius];
	}
};

int main() 
{
	CircleRepository* repository = CircleRepository::getInstance();
	Circle* circle0 = repository->get(100);
	circle0->draw(1, 1);

	Circle* circle1 = repository->get(50);
	circle1->draw(20, 15);

	Circle* circle2 = repository->get(100);
	circle2->draw(10, 50);
	return 0;
}
